<%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://www.rapid-framework.org.cn/rapid" prefix="rapid"%>

<rapid:override name="frame-content">
	<div style="padding: 15px;">
		<blockquote class="layui-elem-quote">
			<span class="layui-breadcrumb" lay-separator="/"> 
				<a href="Login">首页</a> 
				<a href="notice/noticeList">公告列表</a> <a><cite>添加公告</cite></a>
			</span>
		</blockquote>


		<form class="layui-form" method="post" id="myForm" action="notice/addNotice">
			
			<div class="layui-form-item">
				<label class="layui-form-label">标题 
					<span style="color: #FF5722;">*</span>
				</label>
				<div class="layui-input-inline">
					<input type="text" name="noticeTitle" lay-verify="title" id="title" value="" class="layui-input">
				</div>
				<div class="layui-form-mid layui-word-aux" id="noticeTitle_msg"></div>
			</div>

			<div class="layui-form-item layui-form-text">
				<label class="layui-form-label">内容 
					<span style="color: #FF5722;">*</span>
				</label>
				<div class="layui-input-block">
					<textarea class="layui-textarea layui-hide" name="noticeContent" id="content"></textarea>
				</div>
			</div>
			
			<div class="layui-form-item">
				<label class="layui-form-label">排序
					<span style="color: #FF5722;">*</span>
				</label>
				<div class="layui-input-inline">
					<input type="text" name="noticeOrder" lay-verify="title" id="noticeOrder" value="" class="layui-input">
				</div>
				<div class="layui-form-mid layui-word-aux" id="noticeOrder_msg"></div>
			</div>

			<div class="layui-form-item">
				<div class="layui-input-block">
					<button class="layui-btn" lay-submit="" lay-filter="demo1" id="subm">发布</button>
					<button type="reset" class="layui-btn layui-btn-primary">重置</button>
				</div>
			</div>
		</form>

	</div>
</rapid:override>

<rapid:override name="frame-footer-script">

		<link rel="stylesheet" href="resources/kindeditor/themes/default/default.css" />
		<link rel="stylesheet" href="resources/kindeditor/plugins/code/prettify.css" />
		<script charset="utf-8" src="resources/kindeditor/kindeditor-all-min.js"></script> 
		<script charset="utf-8" src="resources/kindeditor/lang/zh-CN.js"></script>
		<script charset="utf-8" src="resources/kindeditor/plugins/code/prettify.js"></script>
		 <script>
		 $(function(){
				
			 //yztitle
				$("#title").blur(titl);
				function titl(){
					var r=false;
					var reg=/^[^\s]{2,20}$/;
					if( !reg.test($("#title").val()) ){
						$("#noticeTitle_msg").html("<font color=red>标题不合法.请输入2-20位字符</font>");
					}else{
						$("#noticeTitle_msg").html("");
						r=true;
					}
					
					return r;
				}
				
				//yznoticeOrder
				$("#noticeOrder").blur(noticeOrde);
				function noticeOrde(){
					var r=false;
					var reg=/^[0-9]{1,3}$/;
					if( !reg.test($("#noticeOrder").val()) ){
						$("#noticeOrder_msg").html("<font color=red>排序不合法.请输入1-3位数字</font>");
					}else{
						$("#noticeOrder_msg").html("");
						r=true;
					}
					
					return r;
				}
				
			 //subm
			 $("#subm").click(function(){
				 var r=true;
				 
				 if(!noticeOrde()){
					 r=false;
				 }
				 
				 if(!titl()){
					 r=false;
				 }
				 
				 if(r){
					 r=confirm("确定发布该公告吗");
				 }
				 return r;
			 });
			 
		 });
		 </script>
			<script>
					KindEditor.ready(function(K) {
						var editor1 = K.create('textarea[id="content"]', {   //指向了页面中 id=content 的那个元素 
					      //cssPath : '../plugins/code/prettify.css',
							uploadJson : 'article/uploadImg',
							//fileManagerJson : '../jsp/file_manager_json.jsp',
							allowFileManager : true,
							width:"1100px",
							height:"420px"
						});
						
						prettyPrint();
					});
			</script>
</rapid:override>

<%@ include file="../framework.jsp" %>